//直播间的封装
import 'package:agora_rtc_engine/rtc_engine.dart';
import 'package:get/get.dart';

import '../../config/base_configuration.dart';

class StreamRTCController extends GetxController {
  late ClientRole clientRole;
  late int id;
  bool joined = false;
  int remoteUid = -1;
  VideoRemoteState remoteState = VideoRemoteState.Stopped;
  late RtcEngine _engine;

  RtcEngine get engine {
    return _engine;
  }

  StreamRTCController({required this.clientRole});

  Future<RtcEngine> initEngine() async {
    // LogUtil.v("初始化引擎");
    RtcEngine engine = await RtcEngine.create(StreamConf.appid);
    await engine.enableVideo();
    await engine.setChannelProfile(ChannelProfile.LiveBroadcasting);
    this._engine = engine;
    return _engine;
  }

  addChannelListener() {}

  //关闭直播全部销毁
  destroy() async {
    if (_engine != null) {
      await _engine.destroy();
      // LogUtil.v("清除对象");
    }
  }
}
